package org.biubiu0002.baiblog.im.component;

import com.alibaba.fastjson.JSON;
import org.biubiu0002.baiblog.im.async.event.SendChatMsgEvent;
import org.biubiu0002.baiblog.im.config.RabbitMqConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author: biubiu0002
 * @Date: 2022/10/25 12:23
 **/
@Component
public class RabbitMqService {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendSendChatMsgEvent(SendChatMsgEvent sendChatMsgEvent){
        rabbitTemplate.convertAndSend(RabbitMqConfig.SEND_CHAT_MSG_EXCHANGE,RabbitMqConfig.SEND_CHAT_MSG_ROUTING_KEY,
                JSON.toJSONString(sendChatMsgEvent));
    }


}
